package chap06.task3;

import com.sun.org.apache.bcel.internal.generic.NEW;

import java.io.*;

/**
 * 创建字节缓冲流对象，通过缓冲流对象实现信息写入文件，以及读取文件内容
 * @author Administrator
 */
public class Task06_03 {
    public static void main(String[] args)throws Exception {
     /*OutputStream out =new FileOutputStream("a.txt");
     BufferedOutputStream bos=new BufferedOutputStream(out);*/
     BufferedOutputStream bos =new BufferedOutputStream(new FileOutputStream("a.txt"));

     String s="Hello Java";
     bos.write(s.getBytes());
     bos.close();

     BufferedInputStream bis=new BufferedInputStream(new FileInputStream("a.txt"));
     byte[] bys=new byte[1024];
     int len=0;
     while ((len=bis.read(bys))!=-1){
         System.out.println(new String(bys,0,len));
     }
    }
}
